//
//  MallHeaderView.m
//  ShouYi
//
//  Created by yrapp on 16/3/9.
//  Copyright © 2016年 yurui. All rights reserved.
//

#import "MallHeaderView.h"
#import "hdlistModel.h"




@implementation MallHeaderView

- (instancetype)initWithFrame:(CGRect)frame imageArray:(NSMutableArray *)imageArray delegate:(id)delegate action:(SEL)action timer:(NSTimeInterval)timer selector:(SEL)selector {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        
#pragma mark ---- 轮播图 ----

        NSMutableArray *lunboArray = [NSMutableArray array];
        
        for (int i = 0; i < imageArray.count ; i++) {
            
            HdListModel *model = imageArray[i];
            [lunboArray addObject:model.picurl];
            
            
        }
        
        
    _picview = [DCPicScrollView picScrollViewWithFrame:CGRectMake(0,0,kWidth,kHeight / 4) WithImageUrls:lunboArray];
        [self addSubview:_picview];
        
        _picview.AutoScrollDelay = 2.0f;
        //下载失败重复下载次数,默认不重复,
        [[DCWebImageManager shareManager] setDownloadImageRepeatCount:1];
        //图片下载失败会调用该block(如果设置了重复下载次数,则会在重复下载完后,假如还没下载成功,就会调用该block)
        //error错误信息
        //url下载失败的imageurl
        [[DCWebImageManager shareManager] setDownLoadImageError:^(NSError *error, NSString *url) {
            NSLog(@"%@",error);
        }];
  
    
    //左一
    _xinButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _xinButton.frame = CGRectMake(24, _picview.frame.size.height + 12.5 + _picview.frame.origin.y, 45,60);
    [_xinButton setImage:[UIImage imageNamed:@"icon_sy_01"] forState:(UIControlStateNormal)];
    [self addSubview:_xinButton];
    
    
    _xin2Button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _xin2Button.frame = CGRectMake(24, _picview.frame.size.height + 12.5 + 45 + 33 + _picview.frame.origin.y, 45, 60);
    [_xin2Button setImage:[UIImage imageNamed:@"icon_sy_02"] forState:(UIControlStateNormal)];
    [self addSubview:_xin2Button];
    
    
    
    //左二
    _hotButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _hotButton.frame = CGRectMake((kWidth - 48 - 4 * 45) / 3 + 69, _xinButton.frame.origin.y, 45, 60);
    [_hotButton setImage:[UIImage imageNamed:@"icon_sy_03"] forState:(UIControlStateNormal)];
    [self addSubview:_hotButton];
    
        
    _hot2Button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _hot2Button.frame = CGRectMake((kWidth - 48 - 4 * 45) / 3 + 69, _xin2Button.frame.origin.y, 45, 60);
    [_hot2Button setImage:[UIImage imageNamed:@"icon_sy_04"] forState:(UIControlStateNormal)];
    [self addSubview:_hot2Button];
    
    //左三
    _cuButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _cuButton.frame = CGRectMake( 2 * (kWidth - 48 - 4 * 45) / 3 + 114, _xinButton.frame.origin.y, 45, 60);
    [_cuButton setImage:[UIImage imageNamed:@"icon_sy_05"] forState:(UIControlStateNormal)];
    [self addSubview:_cuButton];
    
        
    _cu2Button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _cu2Button.frame = CGRectMake( 2 * (kWidth - 48 - 4 * 45) / 3 + 114, _xin2Button.frame.origin.y, 45,60);
    [_cu2Button setImage:[UIImage imageNamed:@"icon_sy_06"] forState:(UIControlStateNormal)];
    [self addSubview:_cu2Button];
    
    //左四
    _teButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _teButton.frame = CGRectMake(kWidth - 69, _xinButton.frame.origin.y, 45, 60);
    [_teButton setImage:[UIImage imageNamed:@"icon_sy_07"] forState:(UIControlStateNormal)];
    [self addSubview:_teButton];
    
       
    _te2Button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    _te2Button.frame = CGRectMake(kWidth - 69, _xin2Button.frame.origin.y, 45, 60);
    [_te2Button setImage:[UIImage imageNamed:@"icon_sy_08"] forState:(UIControlStateNormal)];
    [self addSubview:_te2Button];
    
        
    }
    
    return self;
    
    
}




/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
